﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

namespace WebApplication1
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }

        protected void Button_Click(object sender, EventArgs e)
        {
            Button bt_tmp = (Button)sender;
            if (bt_tmp.Text == "0")
                if (TextBox1.Text == "0")
                    return;
            if (TextBox1.Text == "0")
                TextBox1.Text = "";
            TextBox1.Text = TextBox1.Text + bt_tmp.Text;
        }

        protected void Button10_Click(object sender, EventArgs e)
        {
            if (TextBox1.Text[0] == '-')
                TextBox1.Text = TextBox1.Text.Replace("- ", "");
            else
                TextBox1.Text = "- " + TextBox1.Text;
        }

        protected void Button16_Click(object sender, EventArgs e)
        {
            TextBox1.Text = "0";
            Label1.Text = "";
            Label2.Text = "";
        }

        protected void ButtonAction_Click(object sender, EventArgs e)
        {
            Button bt_tmp = (Button)sender;
            Label1.Text = TextBox1.Text;
            Label2.Text = bt_tmp.Text;
            TextBox1.Text = "0";
        }

        protected void Button11_Click(object sender, EventArgs e)
        {
            int b = 0;
            if (Label2.Text != "")
            {
                switch (Label2.Text)
                {
                    case "+":
                        b = Convert.ToInt16(Label1.Text.Trim()) + Convert.ToInt16(TextBox1.Text.Trim());
                        break;
                    case "-":
                        b = Convert.ToInt16(Label1.Text.Trim()) - Convert.ToInt16(TextBox1.Text.Trim());
                        break;
                    case "x":
                        b = Convert.ToInt16(Label1.Text.Trim()) * Convert.ToInt16(TextBox1.Text.Trim());
                        break;
                    case "/":
                        b = Convert.ToInt16(Label1.Text.Trim()) / Convert.ToInt16(TextBox1.Text.Trim());
                        break;
                }
                TextBox1.Text = b.ToString();
                Label1.Text = "";
                Label2.Text = "";
            }
        }

        protected void UpdatePanel1_Load(object sender, EventArgs e)
        {
           
        }
    }
}
